Skip to content

Size the perspective viewport from the scene bounding radius - #88

Merged
bjmorgan merged 3 commits into
mainfrom
feature/perspective-viewport-bound
Aug 17, 2026
Merged

Size the perspective viewport from the scene bounding radius#88
bjmorgan merged 3 commits into
mainfrom
feature/perspective-viewport-bound

Conversation

@bjmorgan

Copy link
Copy Markdown
Owner

_scene_extent widens the interactive viewport under perspective by the worst-case magnification, but it computed that worst case from atom centre distances alone. The outermost renderable point can be a unit-cell corner or a large atom's surface (centre + display radius) sitting farther out, so a big cell or atom rotating towards the eye magnified more than the viewport was sized for and clipped at the edge.

  • Size the magnification from max_extent — the scene's true bounding radius, which already includes atom surfaces and cell corners — rather than the maximum atom-centre distance. This is a conservative, rotation-invariant bound: any point at distance d projects to a radius no larger than d * scale(d), so it over-sizes rather than clips. Orthographic output is unchanged, because its magnification is always 1.0.
  • Drop the atom-count gate, so a cell with no atoms is now given a perspective allowance too.
  • Make the eye-plane blank-view warning a constant message so it de-duplicates across a viewing-distance keydrag, and remove the assert isinstance downcast it only existed to feed.

_scene_extent is interactive-only and off the static render path, so the change is pinned by unit tests rather than the golden harness; each behavioural test fails on the pre-fix code.

Out of scope, to follow separately: the viewport's zoom recompute on frame navigation, and the unbounded magnification as the eye nears the bounding sphere (recorded as a known limitation, with a near-plane-clipping rework the honest fix rather than a magic-threshold clamp).

Copilot AI lite review requested due to automatic review settings August 17, 2026 08:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

_scene_extent is interactive-only (the static render path autoscales via
matplotlib and never calls it), so its "scene reaches the eye plane"
warning only ever accompanies a render the user can already see.  The
projection's own project_camera warning covers the degenerate case on
both the interactive and headless paths, with better per-frame timing.
Remove the redundant warning, its now-unused imports, and its tests.

Also add an enclosure test that pins the real contract (the viewport
encloses the outermost atom at its worst rotation, not merely exceeds
the un-magnified radius) and an empty-scene magnification test, and trim
the known-limitation comment to observable behaviour.
Copilot AI review requested due to automatic review settings August 17, 2026 09:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bjmorgan
bjmorgan merged commit e352db5 into main Aug 17, 2026
5 checks passed
@bjmorgan
bjmorgan deleted the feature/perspective-viewport-bound branch August 17, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants